package cn.biplam.front.template.control.table.cell;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.template.base.CheckBox;

/**
 * 表格单元格为复选框时单元格模版
 * @author XiaoRuxing 2009-5-22下午02:29:23
 * @version 1.0
 */
public class CheckBoxCell extends Cell{

	/** 复选框 */
	private CheckBox checkBox;
	private int length;

	public CheckBoxCell(){};

	/**
	 * 创建复选框单元格
	 * @param ID        复选框ID
	 * @param value     复选框值
	 * @param sHomeUrl  系统路径
	 * @param sText     复选框显示内容
	 * @throws ErrorMessage
	 */
	public CheckBoxCell(String ID,String value,String sHomeUrl,String sText) throws ErrorMessage{
		_init(ID,value,sHomeUrl,sText);
	}

	private void _init(String ID,String value,String sHomeUrl,String sText) throws ErrorMessage{
		checkBox=new CheckBox(ID,value,sHomeUrl,sText);
		this.length=checkBox.get().getLength();
	}

	/**
	 * 放入多个html对象到单元格
	 * @param html html对象组
	 * @throws ErrorMessage
	 */
	public void put(HtmlWindow... html) throws ErrorMessage{
		for(HtmlWindow ht:html){
			this.put(ht);
			this.length=this.length+ht.getLength();
		}
	}

	/**
	 * 获取checkBox组件宽度
	 * @return
	 * @throws ErrorMessage 
	 */
	public int _getLength(){
		return this.length;
	}

	public void getContent() throws ErrorMessage{
		if(checkBox!=null){
			this.put(checkBox.get());
		}
	}
}
